package cn.eric.framework;

import cn.eric.framework.auth.utils.EAuthUtil;
import cn.eric.framework.exception.utils.EExceptionUtil;
import cn.eric.framework.log.log4j2.Log4Framework;
import org.apache.logging.log4j.Logger;

import javax.annotation.Resource;
import javax.xml.bind.JAXBException;
import java.io.IOException;

/**
 * 用于初始化框架
 */
public class Initializer {
    private static final String LOG_TITLE = "Framework init";

    private String eAuthCfgPath;
    private String eExceCfgPath;

    @Resource
    private Logger logger;
    @Resource
    private EAuthUtil eAuthUtil;
    @Resource
    private EExceptionUtil eExceptionUtil;

    public void init() throws JAXBException, InstantiationException, IllegalAccessException, IOException {
        logger.info(Log4Framework.create(LOG_TITLE, "初始化开始。"));
        logger.info(Log4Framework.create(LOG_TITLE, "EAuth模块"));
        eAuthUtil.initEAuth(eAuthCfgPath);
        logger.info(Log4Framework.create(LOG_TITLE, "统一异常处理模块"));
        eExceptionUtil.initEException(eExceCfgPath);
        logger.info(Log4Framework.create(LOG_TITLE, "初始化完成。"));
    }

    public String geteAuthCfgPath() {
        return eAuthCfgPath;
    }

    public void seteAuthCfgPath(String eAuthCfgPath) {
        this.eAuthCfgPath = eAuthCfgPath;
    }

    public String geteExceCfgPath() {
        return eExceCfgPath;
    }

    public void seteExceCfgPath(String eExceCfgPath) {
        this.eExceCfgPath = eExceCfgPath;
    }
}
